﻿// JScript File
//created by sanal on 25, April, 2012
var default_quick_link_collapsed = "true";
function handleQuickLinks() {
   
    $('#ql').find("div").each(function () {
        if ($(this).attr('id')) {
           
            var curProp = getMB_property($(this).attr('id'), "collapsed");
            //alert(curProp);
            if (curProp == null)
                curProp = default_quick_link_collapsed;
            var st = curProp == "false" ? "block" : "none";
            $(this).css('display', curProp == "false" ? "block" : "none");
            $('#img_' + $(this).attr('id')).attr('src', curProp == "false" ? "Images/collapse3.gif" : "Images/expand3.gif");
        }
    });
}
function rememberProperty(elemid) {
    
    try
    {
        //$.cookie("mb_prop_cache", "", { expires: -1 });
        var defaultproperty = "false";
        defaultproperty = $('#' + elemid).css('display')=="none" ? "true" : "false";
        setMB_property(elemid, "collapsed", defaultproperty)
    }
    catch(Exdep){}
}
function getMB_property(elem, propname)
{
    var ret = null;
    try {
        if($.cookie('mb_prop_cache'))//have MaxBlox property cache
        {
            var props =jQuery.parseJSON($.cookie('mb_prop_cache'));
            var propertyElem = null;
            for(var j=0;j<props.mb_properties.length;j++)
            {
                if (props.mb_properties[j].Key == elem + "_" + propname)
                {
                    ret = props.mb_properties[j].value;
                    break;
                }
            }        
        }
    }
    catch(Exgp){}
    return ret;
}
function setMB_property(elem, propname, propvalue)
{
    try {       
        var props =null;
        if($.cookie('mb_prop_cache'))
            props = jQuery.parseJSON($.cookie('mb_prop_cache'));                
        else
            props = jQuery.parseJSON('{"mb_properties":[        {"key": "elem_prop","value" : "123"}    ]}');
        var mb_key = elem + "_" + propname;  
        var found = false;
        for(var j=0;j<props.mb_properties.length;j++)
            {
                if (props.mb_properties[j].Key == mb_key)
                {
                    props.mb_properties[j].value = propvalue;
                    found=true;
                    break;
                }
            }          
            if (found==false)
                props.mb_properties.push({"Key" : mb_key, 'value' : propvalue });
        var property_cache_string = JSON.stringify(props);
        //alert(property_cache_string);
        $.cookie('mb_prop_cache',property_cache_string,{expires : 365});
    }
    catch(Exset){}
}

function ShowHideChild(div_id) { // Added by 'Imran Gani' on 10-Dec-12, to use Jquery for better animation.
    if ($("#" + div_id).is(":hidden")) 
    {
        $("#img_" + div_id).attr("title", "Click to collapse");
        $("#" + div_id).slideDown("", function () { $(this).css("display", "block"); setMB_property(div_id, "collapsed", "false"); });
        $("#img_" + div_id).attr("src", "Images/collapse3.gif");
    }
    else {
        $("#img_" + div_id).attr("title", "Click to expand");
        $("#" + div_id).slideUp("", function () { $(this).css("display", "none"); setMB_property(div_id, "collapsed", "true"); });
        $("#img_" + div_id).attr("src", "Images/expand3.gif");
    }
}